# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Serge Victor <arch@random.re>
# Contributor: Kevin Azzam <aur@azz.am>

_pyname=flask-sqlalchemy
pkgname=python-flask-sqlalchemy
pkgver=2.5.1
pkgrel=5
pkgdesc='Adds SQLAlchemy support to your Flask application'
url='http://flask-sqlalchemy.pocoo.org/'
arch=('any')
license=('BSD')
depends=('python-flask' 'python-sqlalchemy')
makedepends=('python-setuptools' 'python-sphinx' 'python-pallets-sphinx-themes' 'python-sphinx-issues')
checkdepends=('python-pytest' 'python-blinker' 'python-mock')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/mitsuhiko/flask-sqlalchemy/archive/${pkgver}.tar.gz
        filter-warnings-test.patch)
sha512sums=('6780213b959bbc43306bad97ff6d3bf120baeff26cdaeba84b98b1b5b288a78fcbe80884e5342e8907bdfd2a7acd87aa0a8e761018bf8662b9509c1227b443cd'
            '9cc30ac4650bbd54ee44d3ce9be985edf8c23e1747bd608167afdedde400b7556096d608985e56033867453e0c196193506ba89f298b241fed0a68bc7c593513')

prepare() {
  sed -r "s|(release =)|\\1 '${pkgver}'  #|" -i ${_pyname}-${pkgver}/docs/conf.py
  cd ${_pyname}-${pkgver}
  patch -Np1 -i ${srcdir}/filter-warnings-test.patch
}

build() {
  cd ${_pyname}-${pkgver}
  python setup.py build
  make -j1 -C docs man text SPHINXBUILD=sphinx-build PYTHONPATH=..
}

check() {
  cd ${_pyname}-${pkgver}
  PYTHONPATH=".:${PYTHONPATH}" py.test -vs -Wignore --disable-pytest-warnings
}

package() {
  cd ${_pyname}-${pkgver}
  python setup.py install --root="${pkgdir}" -O1 --skip-build
  install -Dm 644 LICENSE.rst -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 CHANGES.rst README.rst  -t "${pkgdir}/usr/share/doc/${pkgname}"
  cp -r docs/_build/text "${pkgdir}/usr/share/doc/${pkgname}/text"
  install -Dm 644 docs/_build/man/${_pyname}.1 "${pkgdir}/usr/share/man/man1/${pkgname}.1"
}

# vim: ts=2 sw=2 et:
